/**
 * 
 */
package com.wang.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * @author wsf
 * 
 */
public class InOutFromCommandLine {

	public static void readInFromCommandLine(Map<String, String> m) throws IOException {
		readInFromCommandLine(m, null);
	}

	public static void readInFromCommandLine(Map<String, String> m, String charSet) throws IOException {
		BufferedReader br = null;
		if (charSet == null) {
			br = new BufferedReader(new InputStreamReader(System.in));
		} else {
			br = new BufferedReader(new InputStreamReader(System.in, charSet));
		}
		Iterator<String> iter = m.keySet().iterator();
		while (iter.hasNext()) {
			String key = iter.next();
			System.out.println("Please input for " + key);
			String value = br.readLine();
			m.put(key, value);
		}
	}
	
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Map<String, String> m = new HashMap<String, String>();
		m.put("1", "");
		m.put("2", "");
		m.put("3", "");
		m.put("4", "");
		
		try {
			InOutFromCommandLine.readInFromCommandLine(m, "UTF-8");
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		for(String key : m.keySet()) {
			System.out.println(key);
			System.out.println(m.get(key));
		}
	}
}
